#include "pushbutton.h"
#include<QEvent>
#include <QDebug>
#include <QMouseEvent>
PushButton::PushButton(QWidget* parent): QPushButton(parent)
{
}
void PushButton::enterEvent(QEvent *event)
{
    (void) event;
    int x=rand()%geometry().width();
    int y=rand()%geometry().height();
    this->setGeometry(x,y,geometry().width(),geometry().height());
}

void PushButton::leaveEvent(QEvent *event)
{
    (void) event;
    int x=rand()%geometry().width();
    int y=rand()%geometry().height();
    this->setGeometry(x,y,geometry().width(),geometry().height());
}

void PushButton::mousePressEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        qDebug()<<"按下左键，女神非常不接受";
    }
    else if(event->button()==Qt::RightButton)
    {
        qDebug()<<"按下左键，女神一般不接受";
    }
    else
    {
        qDebug()<<"女神默认";
    }
}

void PushButton::mouseReleaseEvent(QMouseEvent *event)
{
    if(event->button()==Qt::LeftButton)
    {
        qDebug()<<"释放右键，女神非常不接受";
    }
    else if(event->button()==Qt::RightButton)
    {
        qDebug()<<"释放右键，女神一般不接受";
    }
    else
    {
        qDebug()<<"女神默认";
    }
}

